//
//  pop_goodView.m
//  penzer
//
//  Created by caiyc on 2018/10/2.
//  Copyright © 2018年 caiyc. All rights reserved.
//

#import "pop_goodView.h"
@interface pop_goodView()<UIGestureRecognizerDelegate>
@property (nonatomic,strong) UIView *alertview;
@property (nonatomic,strong)UILabel *titleLab;
@property (nonatomic,strong)UILabel *messageLab;
@property (nonatomic,strong)UIButton *cancelBtn;
@property (nonatomic,strong)UIButton *otherBtn;
@property(nonatomic,strong)UIImageView *backImg;
@property(nonatomic,strong)UIImageView *left_Img;
@property(nonatomic,strong)UIImageView *right_Img;
@property(nonatomic,strong)UIButton *left_Btn;
@property(nonatomic,strong)UIButton *right_Btn;
@property(nonatomic,strong)UIView *examView;
@property(nonatomic,strong)UIButton *cofirm_Btn;
@property(nonatomic,strong)UIButton *close_Btn;
@end
@implementation pop_goodView

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/
- (IBAction)buy:(Regular_Btn *)sender {
    [self dismissAlertView];
}
- (IBAction)close:(UIButton *)sender {
    [self dismissAlertView];
}
-(instancetype)init{
    self = [super init];
    if(self){
        self.frame = [UIScreen mainScreen].bounds;
        self.alertview = [[[NSBundle mainBundle]loadNibNamed:@"pop_goodView" owner:self options:nil]lastObject];
        self.alertview.backgroundColor = RGBA(0, 0, 0, .8);
        self.alertview.frame = CGRectMake(0, screen_height-400, screen_width, 400);
        self.buy_Btn.layer.cornerRadius = 25;
        [self addSubview:self.alertview];
    }
    
    return self;
}
-(void)show{
    self.backgroundColor = [UIColor clearColor];
    [[UIApplication sharedApplication].keyWindow addSubview:self];
    CGAffineTransform transform = CGAffineTransformScale(CGAffineTransformIdentity,1.0,1.0);
    
    self.alertview.transform = CGAffineTransformScale(CGAffineTransformIdentity,0,0);
    // self.alertview.alpha = 0;
    [UIView animateWithDuration:0.3 delay:0.1 usingSpringWithDamping:0.5 initialSpringVelocity:10 options:UIViewAnimationOptionCurveLinear animations:^{
        self.backgroundColor = [[UIColor blackColor] colorWithAlphaComponent:.4f];
        self.alertview.transform = transform;
        self.alertview.alpha = 1;
    } completion:^(BOOL finished) {
        
    }];
}
-(void)dismissAlertView{
    [UIView animateWithDuration:0.3 animations:^{
        [self removeFromSuperview];
    }];
}
@end
